/*
 * Copyright (c) 2024. Shanghai HEADING information Engineering Co., Ltd. All rights reserved.
 */
package com.lovely602.design.study.basic;

import java.util.Calendar;
import java.util.Date;

/**
 * @author lizhixing
 */
public class CalendarTest {

  public static void main(String[] args) {
    Calendar instance = Calendar.getInstance();

    System.out.println("年：" + instance.get(Calendar.YEAR));
    // 月份是从0开始的，所以要加一
    System.out.println("月：" + (instance.get(Calendar.MONTH) + 1));
    System.out.println("日：" + instance.get(Calendar.DAY_OF_MONTH));
    System.out.println("时：" + instance.get(Calendar.HOUR_OF_DAY));
    System.out.println("分：" + instance.get(Calendar.MINUTE));
    System.out.println("秒：" + instance.get(Calendar.SECOND));

    instance.set(Calendar.MONTH, 5);
    Date time = instance.getTime();
    System.out.println(time.toString());
  }
}
